"use strict";
function fixedEncodeURIComponent (str) {
	return encodeURIComponent(str).replace(/[!'()]/g, escape).replace(/\*/g, "%2A");
}
function reloadPage () {
	location.reload();
}
function update_chars_left (max_len, target_input, display_element) {
	if (typeof target_input === 'undefined' || target_input.length == 0
		|| typeof display_element === 'undefined' || display_element.length == 0) {
		return;
	}
	var lines = target_input.val().split('\n'),
  		enterCharacters = lines.length - 1,
  		text_len = target_input.val().length + enterCharacters;
	if (text_len >= max_len) {
		target_input.val(target_input.val().substring(0, max_len - enterCharacters)); // truncate
		display_element.html('0 remaining');
	} else {
		display_element.html(max_len - text_len + " remaining");
	}
};

/**
 * JIRA COMMON JS
 * 
 * - this section is common js for Jira
 */

function getIssueKey () {
	if (AJS.$('meta[name="ajs-issue-key"]').length > 0) {
		return AJS.$('meta[name="ajs-issue-key"]').attr('content');
	}
	return '';
}

function getAtlToken () {
	if (AJS.$('meta#atlassian-token').length > 0) {
		return AJS.$('meta#atlassian-token').attr('content');
	}
	return '';
}
